package mutsumimod.cards.stand;

import com.megacrit.cardcrawl.actions.watcher.ChangeStanceAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.stances.DivinityStance;
import mutsumimod.actions.TriggerStandAction;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.util.CardStats;

public class BecomeGod extends BaseCard {
    public static final String ID = makeID(BecomeGod.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.SKILL,
            CardRarity.RARE,
            CardTarget.SELF,
            1
    );

    public BecomeGod() {
        super(ID, info);
        standTag=10;
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        this.addToBot(new TriggerStandAction(10, new ChangeStanceAction(DivinityStance.STANCE_ID)));
        if(upgraded) {
            this.addToBot(new TriggerStandAction(10, new ChangeStanceAction(DivinityStance.STANCE_ID)));
        }
//        // TODO 这张卡牌效果很可能不合理,需要平衡调整
//        this.addToBot(new TriggerStandAction(10, new ChangeStanceAction(DivinityStance.STANCE_ID)));
//        /**
//         * 存在bug: 测试时发现有可能在8层触发; 但是我瞪眼觉得逻辑没问题
//         * 怀疑存在ActionManager顺序导致的latestTriggered错误更新
//          */
//        if (TriggerStandAction.latestTriggered && this.upgraded) {
//            // 再触发一次
//            this.addToBot(new NotStanceCheckAction(NeutralStance.STANCE_ID,
//                    new VFXAction(new EmptyStanceEffect(p.hb.cX, p.hb.cY), 0.1F)));
//            this.addToBot(new ChangeStanceAction(NeutralStance.STANCE_ID));
//            this.addToBot(new ChangeStanceAction(DivinityStance.STANCE_ID));
//        }
    }

    @Override
    public void upgrade() {
        if (!this.upgraded) {
            this.upgradeName();
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
        }
    }

    @Override
    public AbstractCard makeCopy() {
        return new BecomeGod();
    }
}
